<div class="page_title">
    <h2 class="fl">{$pageTitle}</h2>
    <div class="fr">
    <a class="top_rt_btn iconfont iconfont-dianji" id="shielding_publish" href="{:U('admin/System/publish')}">发布词库</a>
    <a class="top_rt_btn iconfont iconfont-jia1" href="{:U('admin/System/shielding_add')}">添加</a>
    </div>
    
</div>
<section>
<!--左右分栏：左侧栏目-->
<div class="cont_col_lt" style="min-height:500px;min-width: 80%;">
    <ul class="admin_tab">
        <li><a class="active">{$pageTitle}管理</a></li>
        <li><a>配置</a></li>
    </ul>
    <!--tabCont-->
    <div class="admin_tab_cont" style="display:block;">
        <table class="table">
            <tr>
                <th>关键字</th>
                <th>启用状态</th>
                <th>操作</th>
            </tr>
            {volist name="list.data" id="vo"}
            <tr>
                <td class="center">{$vo.value}</td>
                <td>
                    <input type="checkbox" id="checkbox_live{$i}" data-config_id="{:encrypt_id($vo.config_id)}" class="chk_4 conf_status" {eq name='vo.status' value='1'}checked{/eq} />
                    <label for="checkbox_live{$i}">
                        <input type="hidden" value="{$vo.status}" />
                    </label>
                </td>
                <td>
                    <a href="JavaScript:void(0);"  data-key="{:encrypt_id($vo.config_id)}" class="edit"><i class="iconfont iconfont-bianji inner_btn" style="color: #949496">&nbsp;编辑</i></a>|
                    <a href="JavaScript:void(0);"  data-key="{:encrypt_id($vo.config_id)}" class="delete"><i class="iconfont iconfont-shanchu inner_btn" style="color: #949496">&nbsp;删除</i></a>
                </td>
            </tr>
            {/volist}
        </table>
        <aside class="paging">
            {$list.html}
        </aside>
    </div>
    <div class="admin_tab_cont">
        <ul class="ulColumn2">
            <input type="hidden" name="config_id" value="{:encrypt_id($info.config_id)}" />
            <li>
                <span class="item_name" style="width:120px;">敏感词替换为：</span>
                <input name="replace" type="text" class="textbox textbox_295" value="{$info.value}" placeholder="" />
                <div class="tishi"><i class="iconfont iconfont-tishi"></i>设置之后,敏感词将会被替换成该字符</div>
            </li>
            <li>
                <span class="item_name" style="width:120px;"></span>
                <input type="submit" id="submit" class="link_btn" value="保存"/>
            </li>
    </ul>
    </div>
</div>
<!--左右分栏：右侧栏-->
<div class="cont_col_rt border right_notice" style="max-width: 15%;">
    <div class="iconfont iconfont-suoding1 title"> 提示</div>
    <div class="text">敏感词有调整之后,默认不会重新打包数据,请手动点击右上角发布按钮完成</div>
</div>
</section>
<script>
$(function(){
    $(".conf_status").bind('click',function(){
        var status = $(this).is(":checked") ? 1 : 0;
        var config_id = $(this).data('config_id');
        var send_data = {
            url:U('admin/Config/saveStatus'),
            type:'POST',
            data:{
                status:status,
                config_id:config_id,
                version_key:'filter_version'
            }
        }
        send_ajax(send_data,function(res){
            if(res.status){
                //msg_success(res.data.info);
                return true;
            }else{
                msg_error(res.message);
            }
        });
    });
        /** 点击删除 **/
    $(".delete").click(function(){
        var config_id = $(this).data('key');
        msg({
            yes:'确认',
            no:'取消',
            txt:'从词库中移除?',
        },'question').then(function() {
            var send_data = {
                url:U('admin/System/shielding_delete'),
                data:{config_id:config_id},
                type:'POST',
            };
            send_ajax(send_data,function(response){
                if(response === false){
                    DEBUG && admin.log(ajax_error);
                    return false;
                }
                if(response.status == 1){
                    msg_success('请手动点击更新词库,否则无法同步到移动端',response.data.info,1800);
                    setTimeout(function(){
                        //admin.getContentByUrl(response.data.jumpurl);
                        admin.getContentByUrl(admin.lastGetUrl);
                    },1800);
                }else{
                    msg_error(response.message);
                }
            });
        }, function(miss) {
             //dismiss can be 'cancel', 'overlay', 'close', 'timer'
            //if (miss === 'cancel') {
                //msg('你取消了')
            //}
        });
    });
    /** 点击编辑 **/
    $(".edit").click(function(){
        var config_id = $(this).data('key');
        var url = U("admin/System/shielding_edit")+'?config_id='+config_id;
        admin.getContentByUrl(url);
    });
    //点击提交保存 
    $("#submit").click(function(){
        var send_data = {
              url:U('admin/System/shielding_config'),
              type:'POST',
              data:{
                  keyword:$("input[name='replace']").val(),
                  config_id:$("input[name='config_id']").val(),
              }
        };
        send_ajax(send_data,function(res){
            if(res.status == 1){
                msg_success(res.data.info,'',1000);
                setTimeout(function(){
                    admin.getContentByUrl(res.data.jumpurl);
                },1000);
            }else{
                msg_error(res.message);
            }
        });
    });
    /** 点击发布词库 **/
    $("#shielding_publish").die("click").click(function(e){
        e.preventDefault();
        //阻止事件冒泡 , 防止多次触发点击事件
        e.stopPropagation();
        var send_data = {
              url:U('admin/System/publish'),
              type:'POST',
              data:{
                  type:'filter_word',
              }
        };
        send_ajax(send_data,function(res){
            if(res.status == 1){
                msg_success(res.data.info,'',1000);
            }else{
                msg_error(res.message);
            }
        });
        return true;
    })
})
</script>